package com.tencent.qcloud.tim.uikit.component.photoview;

import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.jojo.android.zxlib.base.BaseDialog;
import com.tencent.qcloud.tim.uikit.R;


/**
 * 创建者 zx
 * 创建时间 2021/2/4 16:47
 */
public class SelectedDialog extends BaseDialog implements View.OnClickListener {
    private final String TAG = "SelectedDialog";
    TextView scan;
    TextView save;
    TextView cancel;

    public SelectedDialog(Activity context) {
        super(context);
    }

    @Override
    protected void init() {
        scan = findViewById(R.id.scan);
        save = findViewById(R.id.save);
        cancel = findViewById(R.id.cancel);
        scan.setOnClickListener(this);
        save.setOnClickListener(this);
        cancel.setOnClickListener(this);
        setCancelable(true);
        setCanceledOnTouchOutside(true);
        //显示在底部
        getWindow().setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        //宽度撑满
        lp.width = -1; //设置宽度
        getWindow().setAttributes(lp);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_popup;
    }

    @Override
    public void onClick(View view) {
        if (view == scan) {
            if (onClickListener != null) {
                onClickListener.onClick(this, 1);
            }
        }
        if (view == save) {
            if (onClickListener != null) {
                onClickListener.onClick(this, 2);
            }
        }
        if (view == cancel) {
            if (onClickListener != null) {
                onClickListener.onClick(this, 3);
            }
        }
    }

}
